<template>
  <div id="app">
    <!-- 通知提示组件 -->
    <notification-component :notifications="notifications" />
    <!-- 其他组件 -->
    <router-view/>
  </div>
</template>

<script>
import { ref, onMounted, onUnmounted } from 'vue'
import NotificationComponent from '@/components/Notification.vue'

export default {
  name: 'App',
  components: {
    NotificationComponent
  },
  setup() {
    const notifications = ref([])

    const handleNewNotification = (notification) => {
      notifications.value.unshift(notification)
      // 可以添加通知提示音效
      // 播放提示音
    }

    onMounted(() => {
      // 监听全局通知事件
      window.addEventListener('new-notification', (event) => {
        handleNewNotification(event.detail)
      })
    })

    onUnmounted(() => {
      window.removeEventListener('new-notification', handleNewNotification)
    })

    return {
      notifications
    }
  }
}
</script>

<style>
#app {
  height: 100vh;
  overflow: hidden;
}

/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #f5f5f5;
}
</style>
